package com.xiaoyu.lanling.feature.chat.model.message

import com.xiaoyu.base.image.ImageLoadInfo
import com.xiaoyu.im.datamodel.AppMessage
import com.xiaoyu.lanling.feature.chat.viewholder.ChatViewHolderManager
import com.xiaoyu.lanling.media.image.ImageLoadParam

class ChatMessageSendImageItem(message: AppMessage) : ChatMessageSendBaseItem(message) {

    private val imageUrl: String? = message.payload.url
    private val imageLoadInfo = ImageLoadInfo(imageUrl)

    val imageDisplayUrl: String = message.payload.localPathOrUrlForMedia
    val height: Int = ChatImageSizer.getImageHeight(imageLoadInfo)
    val width: Int = ChatImageSizer.getImageWidth(imageLoadInfo)
    val imageLoadParam: ImageLoadParam = ImageLoadParam.newBuilder().setWidth(width).setHeight(height).setUrl(imageDisplayUrl).setCornersRadiusInDP(8f).build()

    override val childrenViewType: Int
        get() = ChatViewHolderManager.TYPE_SEND_IMAGE
}